home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
PGM_TOOL
/
PARAMS
/
SKEL1.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-03-24
|
2KB
|
88 lines
program Skel1;
{% an abridged version of Skel.pas without config %}
uses Dos, Params;
const
CopyNote = 'SKEL prototype 11-3-93'; {% change info %}
{ShowUsage: explain command-line parameters and options:}
procedure ShowUsage; far;
begin
writeln(CopyNote);
writeln('Usage:');
{% explain parameters & options here %}
end; {ShowUsage}
{*******************************************************}
{SetOpt: set the option named OptChr to the value given by OptStr:}
{ Uses GetBool for booleans; e.g., /a+ /b /c- : a,b true, c false }
{ Uses GetInt for integers; e.g., /a-16 /b23 : sets a= -16, b= 23 }
{ String values are direct; e.g., /fSomeName : sets f= 'SomeName' }
procedure SetOpt; far;
begin
case OptChr of
{% process option here %}
{% use "if ParNo < 0" for initial-only options %}
'?': begin
PAppDone;
ShowUsage;
Halt;
end;
{none of the above:}
else RptError('Undefined option', Option, 'u');
end;
end; {SetOpt}
{*******************************************************}
{DoFile: process the file (or name) FName:}
procedure DoFile(FName: PathStr; Expdd: boolean); far;
procedure IsFile;
begin
if not Expdd then begin
inc(FileNo); inc(FPars);
end;
end;
begin {DoFile}
{% process file here according to options %}
{% If Expdd = true, FName is expanded name of file found in Dir,
and global variables Path, Dir, and SRec may be used;
else, FName is just the ParStr, and not necessarily a filename.
Use "IsFile" to count FName as a file. %}
end; {DoFile}
{AppDone: prepare to exit from the application:}
procedure AppDone; far;
begin
{% do anything needed for an orderly exit .. but don't halt %}
end; {AppDone}
{*******************************************************}
begin {main program}
{initialize procedure variables:}
PShowUsage:= ShowUsage;
PSetOpt:= SetOpt;
PDoFile:= DoFile;
PAppDone:= AppDone;
if ParamCount = 0 then begin {% optional %}
ShowUsage;
halt;
end;
{% MayExpand:= false; -- if desired to override default %}
{ParNo := 1 to ParamCount used here:}
ScanPars; {scan the command line}
{% process here according to options %}
AppDone;
end.